/*

   This file is part of libmarco
   http://code.google.com/p/libmarco/

This module allows to create and manipulate matrices of bits.
The matrix is maintained as a vector of bits to minimize space wasted. (at most seven bits!).
The matrix is ZERO indexed 
i.e. m[1][1] is the second column, second row.
     m[0][0] is the first column, first row.
     m[0][3] in a 3x3 matrix is an invalid cell.

*/

#include <stdio.h>
#include <stdbool.h>

//Max length of file lines when using matrix_fill_from_file
#define MATRIX_PARSE_LINEBUFFER_SIZE 1024
//Size of the string containing ignore characters
#define MATRIX_PARSE_IGNORE_CHARACTERS_LENGTH 2
//Characters to ignore when parsing, currently <space> and <tab>
#define MATRIX_PARSE_IGNORE_CHARACTERS " \t"

typedef struct bit_matrix_t bit_matrix;



bit_matrix * allocate_matrix(unsigned rows, unsigned cols);
void destroy_matrix(bit_matrix * m);

unsigned get_num_rows(bit_matrix * m);
unsigned get_num_cols(bit_matrix * m);

void set_bit(bit_matrix * m, unsigned row, unsigned col);
void unset_bit(bit_matrix * m, unsigned row, unsigned col);
bool is_bit_set(bit_matrix * m, unsigned row, unsigned col);

//Fill m (a matrix of proper dimensions) by readings bits one by one from f.
// f must be open before this call and it's not closed inside it.
bool matrix_fill_from_file(bit_matrix * m, FILE * f);

void print_matrix(bit_matrix * m);
